﻿//-----------------------------------------------------------------
//
// @(#)$Id: ArrivalGoodsReport.aspx.cs,v 1.0 2013/12/16 9:47:43 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/16 9:47:43 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using ebay.Dal;

public partial class UI_Report_ArrivalGoodsReport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        WebUtility.CheckRight();
        if (!IsPostBack)
        {
            txtQDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
            Bind(DateTime.Now.ToString("yyyyMMdd"));
        }

    }

    void Bind(string QDate)
    {
        Report ag = new Report();
        this.Repeater1.DataSource = ag.GetArrivalGoods(QDate);
        this.Repeater1.DataBind();
    }
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        string qDate = txtQDate.Value;
        DateTime dt;
        if (!DateTime.TryParse(qDate, out dt))
        {
            WebUtility.ShowMsg("日期格式有误:" + qDate, this);
        }
        else {
            Bind(dt.ToString("yyyyMMdd"));
        }
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)
        {
            WebUtility.ShowMsg("登陆超时,请重新登陆", this);
            return;
        }
        string qDate = txtQDate.Value;
        DateTime dt;
        if (!DateTime.TryParse(qDate, out dt))
        {
            WebUtility.ShowMsg("日期格式有误:" + qDate, this);
        }
        else
        {
            Report ag = new Report();
            DataTable table = ag.GetArrivalGoods(dt.ToString("yyyyMMdd"));
            if (table != null)
            {
                DataSetToExcel.DataSetOutExcel(table, "到货商品表");
            }
            else
            {
                WebUtility.ShowMsg("无数据", this);

            }
        }
    }
}
